function [ dataset ] = getData(name)

load_settings;

%% Get data. Possible sets:
% SANDBOX_RUN1          = Original dataset labeled by WashU ppl. 11 cameras
% SANDBOX_RUN2          = 2nd dataset labeled by WashU ppl. 39 cameras
% LIVE_MTURK            = Results from live run
% ITER_DATA             = Iterative data from Abby
% SPECIAL_ITER         = Iterative with random negative examples
% SR1_ITER_IMPROVED     = Sandbox_run1 improved with iter baseline
% SR1_ITER_IMPROVED_V2  = Sandbox_run1 improved with iter baseline, using Robert's code

switch name
    %% Old Mturk data - original sandbox run labeled by WashU ppl
    case 'SANDBOX_RUN1'
        disp('getData: Getting SANDBOX_RUN1');
        if exist([data_root 'clean_data/sandbox_run1.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/sandbox_run1.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            old_mturk_data = clean([mturk_root 'parse_all_tab.txt'], true, true);
            old_mturk_data = computeHogs(old_mturk_data);
            old_mturk_data = organize(old_mturk_data);
            dataset = old_mturk_data;
            data = dataset;
            save([data_root 'clean_data/sandbox_run1.mat'], 'data');
        end
        
        %% Sandbox run 2 - Additional 39 cameras labeled by WashU ppl (i.e. backup job)
    case 'SANDBOX_RUN2'
        disp('getData: Getting SANDBOX_RUN2');
        if exist([data_root 'clean_data/sandbox_run2.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/sandbox_run2.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            backup_data = clean([mturk_root 'back.results'], false, true);
            backup_data = computeHogs(backup_data);
            backup_data = organize(backup_data);
            dataset = backup_data;
            data = dataset;
            save([data_root 'clean_data/sandbox_run2.mat'], 'data');
        end
        
        %% Mturk data - results from live run
    case 'LIVE_MTURK'
        disp('getData: Getting LIVE_MTURK_DATA');
        if exist([data_root 'clean_data/live_mturk.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/live_mturk.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            live_inp = clean([mturk_root 'external_hit.results'], false, true);
            mturk_data = computeHogs(live_inp);
            mturk_data = organize(mturk_data);
            dataset = mturk_data;
            data = dataset;
            save([data_root 'clean_data/live_mturk.mat'], 'data');
        end
        
        %% Iterative data - Abby & Robert. Mostly Abby
    case 'ITER_DATA'
        % Not all files in the iterative mats folder are input, some are temp
        % results files
        disp('getData: Getting ITER_DATA');
        if exist([data_root 'clean_data/iter_data.mat'], 'file')
            disp([name '.mat exists, using stored values']);
            load([data_root 'clean_data/iter_data.mat']);
            dataset = data;
        else
            disp([name '.mat does not exist, recomputing']);
            iter_data = [];
            files = {'2rects.mat',    '5rects.mat',    '1147rects.mat', '1217rects.mat', ...
                '1411rects.mat', '19443rects.mat','4169rects.mat', '4170rects.mat', ...
                '7270rects.mat', '7271rects.mat', '7272rects.mat', '8208rects.mat', ...
                '8210rects.mat', '8445rects.mat', '8675rects.mat', '8794rects.mat', ...
                '9164rects.mat', '9481rects.mat', '9507rects.mat', '9704rects.mat'};
            % probably don't need to call appendData here, since they don't overlap (or
            % shouldn't)
            for ix = 1:length(files)
                iter_data = [iter_data, mat2data([iter_root files{ix}])];
            end
            iter_data = checkRects(iter_data, false);
            iter_data = computeHogs(iter_data);
            iter_data = organize(iter_data);
            dataset = iter_data;
            data = dataset;
            save([data_root 'clean_data/iter_data.mat'], 'data');
        end
        
        %% Iter data with random negative examples, balanced, i.e. special_iter
    case 'SPECIAL_ITER'
        disp('getData: Getting SPECIAL_ITER');
        if exist([data_root 'clean_data/special_iter.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/special_iter.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            special_iter = [];
            files = {'2rects.mat',    '5rects.mat',    '1147rects.mat', '1217rects.mat', ...
                '1411rects.mat', '19443rects.mat','4169rects.mat', '4170rects.mat', ...
                '7270rects.mat', '7271rects.mat', '7272rects.mat', '8208rects.mat', ...
                '8210rects.mat', '8445rects.mat', '8675rects.mat', '8794rects.mat', ...
                '9164rects.mat', '9481rects.mat', '9507rects.mat', '9704rects.mat'};
            % probably don't need to call appendData here, since they don't overlap (or
            % shouldn't)
            for ix = 1:length(files)
                special_iter = [special_iter, mat2data([iter_root files{ix}])];
            end
            
            for ix = 1:size(special_iter,1)
                special_iter(ix).bg_rects = []; % Want same number of pos and negs?
                if isempty(special_iter(ix).ppl_rects)
                    special_iter(ix) = [];
                end
            end
            special_iter = checkRects(special_iter, true);
            special_iter = computeHogs(special_iter);
            special_iter = organize(special_iter);
            dataset = special_iter;
            data = dataset;
            save([data_root 'clean_data/special_iter.mat'], 'data');
        end
    case 'SR1_ITER_IMPROVED'
        disp('getData: Getting SR1_ITER_IMPROVED');
        if exist([data_root 'clean_data/sr1_iter_improved.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/sr1_iter_improved.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            dataset = improveDataset('SANDBOX_RUN1', 'iter_model');
            data = dataset;
            save([data_root 'clean_data/sr1_iter_improved.mat'], 'data');
        end
    case 'SR1_ITER_IMPROVED_V2'
        disp('getData: Getting SR1_ITER_IMPROVED_V2');
        if exist([data_root 'clean_data/sr1_iter_improved_v2.mat'], 'file')
            disp(['getData: ' name '.mat exists, using stored values']);
            load([data_root 'clean_data/sr1_iter_improved_v2.mat']);
            dataset = data;
        else
            disp(['getData: ' name '.mat does not exist, recomputing']);
            dataset = improveSet('SANDBOX_RUN1', 'iter_model');
            for ix = 1:size(dataset,1)
                for jx = 1:size(dataset,2)
                    dataset(ix,jx).ppl_rects = round(dataset(ix,jx).ppl_rects); 
                end
            end
            data_dims = size(dataset);
            dataset = computeHogs(dataset(:));
            data = reshape(dataset, data_dims);
            save([data_root 'clean_data/sr1_iter_improved_v2.mat'], 'data');
        end
    otherwise
        disp(['Loading mat file: ', name]);
        load(name);
        dataset = data;
        
end
disp('Done getting data');
end
